package cn.jobstart.config;




import cn.jobstart.props.FileConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.io.File;

/**
 * @author sunke
 * @Date 2018/8/16 10:32
 * @description
 */
@Configuration
public class MyWebMvcConfigurer implements WebMvcConfigurer {


/*    @Value("${file.upload.root}")
    private String filePath;*/


    @Autowired
    private FileConfig fileConfig;


    @Value("${debugRun}")
    private boolean debug;
    @Value("${rightsDebug}")
    private boolean rightsDebug;



    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        registry.addResourceHandler("/js/**").addResourceLocations("classpath:/static/js/");
        registry.addResourceHandler("/frame/**").addResourceLocations("classpath:/static/frame/");
        registry.addResourceHandler("/style/**").addResourceLocations("classpath:/static/style/");
        registry.addResourceHandler("/images/**").addResourceLocations("classpath:/static/images/");
        registry.addResourceHandler("/fonts/**").addResourceLocations("classpath:/static/fonts/");
        registry.addResourceHandler("swagger-ui.html")
                .addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**")
                .addResourceLocations("classpath:/META-INF/resources/webjars/");

        registry.addResourceHandler("/files/**").addResourceLocations("file:///" + fileConfig.getRoot() + File.separator);
    }







}
